<script>
	import APPUpdate from '@/common/appUpdate.js';
	// #ifdef APP-PLUS
	const jyJPush = uni.requireNativePlugin('JY-JPush');
	// #endif
	export default {
		onLaunch: function() {
			// #ifdef APP-PLUS
			// APPUpdate();
			jyJPush.addJYJPushReceiveNotificationListener(result => {
				//  监听成功后，若收到推送，会在result返回对应的数据；数据格式保持极光返回的安卓/iOS数据一致
				console.info("收到推送1：：")
				console.log(JSON.stringify(result));
				// Voice(result.notificationContent);
			})
			jyJPush.addJYJPushReceiveOpenNotificationListener(result => {
				//  监听成功后，若点击推送消息，会触发result；数据格式保持极光返回的安卓/iOS数据一致
				console.info("收到推送2：：")
				console.log(JSON.stringify(result));
				// Voice(result.notificationContent);
				uni.showToast({
					icon: 'none',
					title: '您收到了系统消息，请注意查看'
				})
			});
			
			//this.addJYJPushReceiveOpenNotificationListener();//监听点击通知栏消息事件
			// #endif
			
			
			
			//	代码示例，此两项代码可以放到App.vue
			//this.addJYJPushReceiveNotificationListener();//监听消息通知事件
			
			// this.addJYJPushReceiveBackgroudNotificationListener();
			//this.addJYJPushCustomReceiveNotificationListener();//监听自定义消息
			
			// setTimeout(function() {
			// 	const jyJPush = uni.requireNativePlugin('JY-JPush');
			// 	jyJPush.getLastPushInfo(result => {
			// 		if (result != null) {
			// 			uni.showToast({
			// 				icon: 'none',
			// 				title: 'last' + JSON.stringify(result)
			// 			})
			// 		}
			// 		});
						
			// }, 500);
			
			// plus.ios.importClass('UIApplication').sharedApplication().registerForRemoteNotifications();
			// plus.ios.importClass('UIApplication').sharedApplication().registerForRemoteNotifications();
		},
		methods: {
			//监听点击通知栏消息事件
			addJYJPushReceiveOpenNotificationListener() {
				jyJPush.addJYJPushReceiveOpenNotificationListener(result => {
					uni.showToast({
						icon: 'none',
						title: 'open' + JSON.stringify(result)
					})
					console.log('打开了' + JSON.stringify(result));
				});
			},
			//监听消息通知事件
			addJYJPushReceiveNotificationListener() {
				const jyJPush = uni.requireNativePlugin('JY-JPush');
				jyJPush.addJYJPushReceiveNotificationListener(result => {
					uni.showToast({
						icon: 'none',
						title: 'rec' + JSON.stringify(result)
					})
					console.log('收到了' + JSON.stringify(result));
				});
			},
			addJYJPushReceiveBackgroudNotificationListener(){
				const jyJPush = uni.requireNativePlugin('JY-JPush');
				jyJPush.addJYJPushReceiveBackgroudNotificationListener(result => {
					uni.showToast({
						icon: 'none',
						title: 'recback' + JSON.stringify(result)
					})
					console.log('后台收到了' + JSON.stringify(result));
				});
				
			},
			//监听自定义消息
			addJYJPushCustomReceiveNotificationListener() {
				const jyJPush = uni.requireNativePlugin('JY-JPush');
				jyJPush.addJYJPushCustomReceiveNotificationListener(result => {
					uni.showToast({
						icon: 'none',
						title: 'ReceiveCustomNotificationListener' + JSON.stringify(result),
					})
			
					
				});
			}
		}
	}
</script>
<style>
	/*每个页面公共css */
	@import './common/index.css';
	@import 'http://at.alicdn.com/t/font_3308249_69ose8h8aig.css';
	@import 'https://at.alicdn.com/t/font_1884679_4io1cmdlnds.css';
</style>
<style lang="scss">
	@import "@/uni_modules/uview-ui/index.scss";
</style>